/*
**  Apache License, Version 2.0
**  Notes:Use this command to anonymously check out the latest project source code:
**  Non-members may check out a read-only working copy anonymously over HTTP.
**  SVN checkout http://YHHCatiaBaseUtlWsp.googlecode.com/svn/trunk/ 
**
**  Author:		Kevin Yang
**  Email:		Bigearrabbit@qq.com
**
**  DATE:		2013-4-4
**
**  File Name:	YHHCatalogParameter.cpp
**
**  Notes:
** 
*/
#include "YHHCatalogParameter.h"
#include "iostream.h"

//CAT
#include "CATISpecAttribute.h"
//-----------------------------------------------------------------------------
YHHCatalogParameter::YHHCatalogParameter()
{
}
//-----------------------------------------------------------------------------
YHHCatalogParameter::~YHHCatalogParameter()
{
}
//-----------------------------------------------------------------------------
YHHCatalogParameter::YHHCatalogParameter(const YHHCatalogParameter& original)
{
	* this = original;
}
//-----------------------------------------------------------------------------
YHHCatalogParameter& YHHCatalogParameter::operator=(const YHHCatalogParameter& original)
{
	AttrName = original.AttrName;//copy value
	AttrType = original.AttrType;//copy value
	AttrInOut = original.AttrInOut;//copy value
	IsList	= original.IsList;//islist
   return *this;
}
//-----------------------------------------------------------------------------
HRESULT YHHCatalogParameter::CatalogAddAttribute	(CATISpecObject *ipSpecOnStartUp,
												 YHH::ListV<YHHCatalogParameter> & iListParam )
{
	if (!ipSpecOnStartUp)return E_INVALIDARG;//check

	HRESULT rc = S_OK;//ok
	// Adding  attribute : 
	for (int i=0;i<iListParam.size();i++)
	{
		YHHCatalogParameter & curParam = iListParam.at(i);//new param

		//chek name exist:


		//if not exist
		CATISpecAttribute *piSpecAttribute = NULL;//null
		if (curParam.IsList)//list
		{
			piSpecAttribute = ipSpecOnStartUp->
				AddAttribute(curParam.AttrName,tk_list(curParam.AttrType),curParam.AttrInOut);
		}
		else
		{//not list
			piSpecAttribute = ipSpecOnStartUp->
				AddAttribute(curParam.AttrName,curParam.AttrType,curParam.AttrInOut);
		}

		if ( piSpecAttribute != NULL ) 
		{
			cout << curParam.AttrName<<" attribute added OK." << endl << flush;
		}
		else 
		{
			cout << "    ERROR in adding "<<curParam.AttrName<<" attribute." << endl << flush;
			rc= E_FAIL;//return ;
		}
		piSpecAttribute->Release();//release
		piSpecAttribute = NULL ;
	}//for i
	return rc;//HRESULT
}
//-----------------------------------------------------------------------------
void YHHCatalogParameter::SetValue	(const CATUnicodeString& iName,
									 CATAttrKind iType,
									 CATAttrInOut iFacet )
{
	AttrName = iName;//copy value
	AttrType = iType;//copy value
	AttrInOut = iFacet;//copy value
	IsList = false;
}
//-----------------------------------------------------------------------------
void YHHCatalogParameter::SetTKListValue	(const CATUnicodeString& iName,
				 CATAttrKind iType,
				 CATAttrInOut iFacet )
{
	AttrName = iName;//copy value
	AttrType = iType;//copy value
	AttrInOut = iFacet;//copy value
	IsList = true;
}
